//
//  FormatViewController.m
//  CategoryKit
//
//  Created by xinpenghui on 16/12/6.
//  Copyright © 2016年 Wanda. All rights reserved.
//

#import "FormatViewController.h"
#import "AppUIDefine.h"
#import "FFFormat.h"
//#import "FFDateTools.h"

#import "NSString+Safe.h"

@interface FormatViewController ()
@property (nonatomic, strong) UITextView *tfView;
@property (nonatomic, strong) NSString *resString;
@end

@implementation FormatViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];

    self.title = @"Format";
    
    _tfView = [[UITextView alloc] initWithFrame:CGRectMake(20, 0, kDefaultWindowWidth-40, kDefaultWindowHeight-64)];
    _tfView.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:_tfView];
    self.resString = @"";

    [self dateValidet]; //时间校验
    [self stringValidet]; //字符串校验

    [self safeTest]; //字符串safe校验
    /**
     NSArray的Category的方法
     对NSArray进行Json转换
     */
    [self arrayTestCase]; //数组
    /**
     NSData的Category的方法
     对NSData进行Json转换
     测试用例为字典类型
     */
    [self dataTestCase];
    /**
     NSDate的Category的方法
     对NSDate进行Json转换
     测试用例为字典类型
     */
    [self dateTestCase];
    /**
     NSDictionary的Category的方法
     对NSDictionary进行Json转换
     */
    [self dictionaryTestCase];
    /**
     NSError的Category的方法
     对NSError进行Json转换
     */
    [self nserrorTestCase];
    
    [self nstimerTestCase];
    
    [self urlTestCase];
}


/**
 NSArray的Category的方法
 对NSArray进行Json转换
 */
- (void)arrayTestCase {
    
    NSArray *testArray = @[@"123",@"345",@"543"];
    self.resString = [self.resString stringByAppendingFormat:@"NSArray Category kit Test Case = %@\n",[testArray jsonStringEncoded]];
    // erro test
    NSArray *testArray1 = nil;
    self.resString = [self.resString stringByAppendingFormat:@"NSArray Category kit Error Test Case = %@\n",[testArray1 jsonStringEncoded]];
    
    self.tfView.text = self.resString;
}

/**
 NSData的Category的方法
 对NSData进行Json转换 
 测试用例为字典类型
 */
- (void)dataTestCase {
    NSData* xmlData = [@"{\"boolean\": true,\"number\": 123,}" dataUsingEncoding:NSUTF8StringEncoding];
    self.resString = [self.resString stringByAppendingFormat:@"NSData Category kit Test Case = %@\n",[xmlData jsonValueDecoded]];
    // error test
    NSData* xmlData1 = nil;
    self.resString = [self.resString stringByAppendingFormat:@"NSData Category kit Error Test Case = %@\n",[xmlData1 jsonValueDecoded]];
    
    self.tfView.text = self.resString;
}

/**
 NSDictionary的Category的方法
 对NSDictionary进行Json转换
 */
- (void)dictionaryTestCase {
    
    NSDictionary *testDic = @{@"num1":@"123",@"num2":@"345",@"num3":@"543"};
    self.resString = [self.resString stringByAppendingFormat:@"NSDictionary Category kit Test Case = %@\n",[testDic jsonStringEncoded]];
    // erro test
//    NSArray *testArray1 = nil;
    self.resString = [self.resString stringByAppendingFormat:@"NSDictionary Category kit prettyPrintedStr Test Case = %@\n",[testDic prettyPrintedStr]];
    
    self.tfView.text = self.resString;
}

/**
 NSError的Category的方法
 对NSError进行Json转换
 */
- (void)nserrorTestCase {
    
    NSError *error = [[NSError alloc] initWithDomain:@"" code:200 userInfo:@{@"response":@{@"message":@"OK"}}];
    self.resString = [self.resString stringByAppendingFormat:@"NSError Category kit Test Case = %@\n",[error errorMessage]];
    // erro test
    //    NSArray *testArray1 = nil;
//    self.resString = [self.resString stringByAppendingFormat:@"NSDictionary Category kit prettyPrintedStr Test Case = %@\n",[testDic prettyPrintedStr]];
    
    self.tfView.text = self.resString;
}

- (void)nstimerTestCase {
    NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:1 block:^{
        NSLog(@"test timer block");
    } repeats:NO];
    
    NSTimer *timer1 = [NSTimer timerWithTimeInterval:1 repeats:NO block:^(NSTimer * _Nonnull timer) {
        NSLog(@"test timer block timer =%@",timer);
    }];
}

- (void)urlTestCase {
    NSURL *url = [NSURL URLWithString:@"http://info.wanda.cn/ddd/a.htm?aa=44"];
    self.resString = [self.resString stringByAppendingFormat:@"url param=%@",url.params];
    self.resString = [self.resString stringByAppendingString:url.protocol];
    self.tfView.text = self.resString;
}

/**
 NSDate的Category的方法
 对NSDate进行Json转换
 测试用例为字典类型
 */
- (void)dateTestCase {
    NSDate *date1 = [NSDate date];
    self.resString = [self.resString stringByAppendingFormat:@"NSDate Category kit Test Case date1 = %@\n",[date1 localeDate]];
    self.resString = [self.resString stringByAppendingFormat:@"NSDate Category kit Test Case date1 billMonthName= %@\n",[date1 billMonthName]];
    //dateStringFromTimeStampString
    self.resString = [self.resString stringByAppendingFormat:@"NSDate Category kit Test Case = %@\n",[NSDate dateStringFromTimeStampString:@"1481774552000" withFormat:@"yyyy-MM-dd HH:mm:ss"]];
    
    
    self.resString = [self.resString stringByAppendingFormat:@"\ndate validate\ndateTomorrow = %@\n",[NSDate dateTomorrow]];
    self.resString = [self.resString stringByAppendingFormat:@"dateYesterday = %@\n",[NSDate dateYesterday]];
    
    self.resString = [self.resString stringByAppendingFormat:@"dateWithDaysFromNow 1 days = %@\n",[NSDate dateWithDaysFromNow:1]];
    self.resString = [self.resString stringByAppendingFormat:@"dateWithDaysBeforeNow 1 days = %@\n",[NSDate dateWithDaysBeforeNow:1]];
    self.resString = [self.resString stringByAppendingFormat:@"dateWithHoursFromNow 2 hours = %@\n",[NSDate dateWithHoursFromNow:2]];
    
    self.resString = [self.resString stringByAppendingFormat:@"dateWithHoursBeforeNow 12 hours = %@\n",[NSDate dateWithHoursBeforeNow:12]];
    self.resString = [self.resString stringByAppendingFormat:@"dateWithHoursBeforeNow 12 hours String = %@\n",[NSDate stringWithDate:[NSDate dateWithHoursBeforeNow:12] format:@"yyyy-MM-dd hh:mm:ss"]];
    self.resString = [self.resString stringByAppendingFormat:@"dateWithMinutesFromNow 60 min = %@\n",[NSDate dateWithMinutesFromNow:60]];
    self.resString = [self.resString stringByAppendingFormat:@"dateWithMinutesBeforeNow 60 min = %@\n",[NSDate dateWithMinutesBeforeNow:60]];
    self.resString = [self.resString stringByAppendingFormat:@"dateWithMinutesBeforeNow 60 is equal date = %d\n",[date1 isEqualToDate:[NSDate dateWithMinutesBeforeNow:60]]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 isToday = %d\n",[date1 isToday]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 isTomorrow = %d\n",[date1 isTomorrow]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 isYesterday = %d\n",[date1 isYesterday]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 isSameWeekAsDate = %d\n",[date1 isSameWeekAsDate:[NSDate dateWithMinutesBeforeNow:60]]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 isThisWeek = %d\n",[date1 isThisWeek]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 isNextWeek = %d\n",[date1 isNextWeek]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 isLastWeek = %d\n",[date1 isLastWeek]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 isSameYearAsDate = %d\n",[date1 isSameYearAsDate:[NSDate dateWithMinutesBeforeNow:60]]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 isThisYear = %d\n",[date1 isThisYear]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 isNextYear = %d\n",[date1 isNextYear]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 isLastYear = %d\n",[date1 isLastYear]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 isEarlierThanDate = %d\n",[date1 isEarlierThanDate:[NSDate dateWithMinutesBeforeNow:60]]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 isLaterThanDate = %d\n",[date1 isLaterThanDate:[NSDate dateWithMinutesBeforeNow:60]]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 dateByAddingDays x day = %@\n",[date1 dateByAddingDays:1]];
    //后退天数
    self.resString = [self.resString stringByAppendingFormat:@"date1 dateBySubtractingDays 2 = %@\n",[date1 dateBySubtractingDays:2]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 dateByAddingHours 10 = %@\n",[date1 dateByAddingHours:10]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 dateBySubtractingHours 10 = %@\n",[date1 dateBySubtractingHours:10]];
    
    self.resString = [self.resString stringByAppendingFormat:@"date1 dateByAddingMinutes 10 = %@\n",[date1 dateByAddingMinutes:10]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 dateBySubtractingMinutes 10 = %@\n",[date1 dateBySubtractingMinutes:10]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 dateAtStartOfDay  = %@\n",[date1 dateAtStartOfDay]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 minutesAfterDate  = %zd\n",[date1 minutesAfterDate:[NSDate dateWithMinutesBeforeNow:60]]];
    
    self.resString = [self.resString stringByAppendingFormat:@"date1 minutesBeforeDate  = %zd\n",[date1 minutesBeforeDate:[NSDate dateWithMinutesBeforeNow:60]]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 hoursAfterDate 10 = %zd\n",[date1 hoursAfterDate:[NSDate dateWithMinutesBeforeNow:60]]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 hoursBeforeDate 10 = %zd\n",[date1 hoursBeforeDate:[NSDate dateWithMinutesBeforeNow:60]]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 daysAfterDate 10 = %zd\n",[date1 daysAfterDate:[NSDate dateWithMinutesBeforeNow:60]]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 daysBeforeDate 10 = %zd\n",[date1 daysBeforeDate:[NSDate dateWithMinutesBeforeNow:60]]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 nearestHour = %zd\n",[date1 nearestHour]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 hour = %zd\n",[date1 hour]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 minute = %zd\n",[date1 minute]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 seconds = %zd\n",[date1 seconds]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 day = %zd\n",[date1 day]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 month = %zd\n",[date1 month]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 weekOfYear = %zd\n",[date1 weekOfYear]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 weekday 10 = %zd\n",[date1 weekday]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 nthWeekday 10 = %zd\n",[date1 nthWeekday]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 year 10 = %zd\n",[date1 year]];
    self.resString = [self.resString stringByAppendingFormat:@"date1 weekString = %@\n",[date1 weekString]];
    
    NSDate *date = [NSDate date];
    self.resString = [self.resString stringByAppendingFormat:@"date relativedDateWithInterval = %@\n",[date relativedDateWithInterval:2]];
    self.resString = [self.resString stringByAppendingFormat:@"relativedDateWithInterval = %@\n",[NSDate relativedDateWithInterval:2]];
    self.resString = [self.resString stringByAppendingFormat:@"dateWithString = %@\n",[NSDate dateWithString:@"2016/12/6 18:10:23" formate:@"YYYY-MM-dd HH:mm:ss"]];
    self.resString = [self.resString stringByAppendingFormat:@"weekdayString = %@\n",[date weekdayString]];
    self.resString = [self.resString stringByAppendingFormat:@"dayTimeString = %@\n",[date dayTimeString]];
    self.resString = [self.resString stringByAppendingFormat:@"stringWithSeperator = %@\n",[date stringWithSeperator:@":"]];
    self.resString = [self.resString stringByAppendingFormat:@"stringWithFormat = %@\n",[date stringWithFormat:@"YYYY-MM-dd"]];
    self.resString = [self.resString stringByAppendingFormat:@"stringWithSeperator = %@\n",[date stringWithSeperator:nil includeYear:NO]];
    self.resString = [self.resString stringByAppendingFormat:@"timeStamp = %@\n",[NSDate timeStamp]];
    self.resString = [self.resString stringByAppendingFormat:@"stringTodayShow = %@\n",[NSDate stringTodayShow:[NSNumber numberWithInteger:1481019023]]];
    self.resString = [self.resString stringByAppendingFormat:@"hoursStringWithTime = %@\n",[NSDate hoursStringWithTime:[NSNumber numberWithInteger:1481019023]]];
    self.resString = [self.resString stringByAppendingFormat:@"timeStringWithInterval = %@\n",[NSDate timeStringWithInterval:1481107540562]];
    
    self.resString = [self.resString stringByAppendingFormat:@"stringWithDate = %@\n",[NSDate stringWithDate:[NSDate dateWithString:@"2016/12/1 18:10:23" formate:@"YYYY-MM-dd HH:mm:ss"] format:@"YYYY-MM-dd HH:mm:ss Z"]];
    
    //////////////error test ////////////
    self.resString = [self.resString stringByAppendingFormat:@"======erro 测试======\n"];
    self.resString = [self.resString stringByAppendingFormat:@"date 方法=%@\n",[date relativedDateWithInterval:1]]; //>0之后多少天 <0之前多少天
    self.resString = [self.resString stringByAppendingFormat:@"%@\n",[NSDate relativedDateWithInterval:2]];
    self.resString = [self.resString stringByAppendingFormat:@"%@\n",[NSDate dateWithString:@"2016-12-06 18:10:23 +0800" formate:@"YYYY-MM-dd HH:mm:ss Z"]];
    self.resString = [self.resString stringByAppendingFormat:@"%@\n",[NSDate stringWithDate:[NSDate dateWithString:@"2016-12-06 18:10:23" formate:@"YYYY-MM-dd HH:mm:ss"] format:@"YYYY-MM-dd HH:mm:ss Z"]];
    self.resString = [self.resString stringByAppendingFormat:@"%@\n",[date stringWithSeperator:@"&&"]];//任意字符均可
    self.resString = [self.resString stringByAppendingFormat:@"%@\n",[date stringWithFormat:@"YYYY-MM-dd"]];
    
    self.resString = [self.resString stringByAppendingFormat:@"%@\n",[NSDate getDefaultTimeZone]];
    self.resString = [self.resString stringByAppendingFormat:@"%@\n",[date stringWithSeperator:nil includeYear:NO]];
    
    self.resString = [self.resString stringByAppendingFormat:@"\n\n%@\n",[date localeDate]];
    self.resString = [self.resString stringByAppendingFormat:@"%@\n",[date billMonthName]];
    self.resString = [self.resString stringByAppendingFormat:@"%@\n",[NSDate dateStringFromTimeStampString:@"1481019023000" withFormat:@"YYYY-MM-dd"]];

    self.tfView.text = self.resString;
}

- (void)safeTest {
    NSNull *null = [NSNull null];
    NSLog(@"null test = %@",[NSString safeStringFromObject:null]);
    //safeFormatString
    NSLog(@"null2 test =%@= %@",nil,[NSString safeFormatString:@"(null)"]);
}

- (void)stringValidet {
    NSString *string = [NSString stringWithFormat:@"string validate\n\n"];
    string = [string stringByAppendingFormat:@"%@\n",[@"123456" md5]];
    string = [string stringByAppendingFormat:@"%@\n",[@"123456" sha1]];
    string = [string stringByAppendingFormat:@"%ld\n",[@"123456" longValue]];
    string = [string stringByAppendingFormat:@"%@\n",[@"   1 34" trimWhiteSpace]];
    NSString *st =[@"中文测试" urlencode];
    string = [string stringByAppendingFormat:@"%@\n",st];
    string = [string stringByAppendingFormat:@"%@\n",[st urldecode]];
    string = [string stringByAppendingFormat:@"%@\n",[@"{\"boolean\": true,\"number\": 123,}" jsonValueDecoded]];
    string = [string stringByAppendingFormat:@"%@\n",[@"0.00" stringWithCustomPriceFormat]];
    
    string = [string stringByAppendingFormat:@"%zd\n",[@"123er4" isStrengthPwd]];
    string = [string stringByAppendingFormat:@"%@\n",[@"123-450" stringToNumberString]];
    string = [string stringByAppendingFormat:@"%@\n",[NSString stringTenPaySourceApplication]];
    string = [string stringByAppendingFormat:@"%@\n",[NSString stringAlixPaySourceApplication]];
    string = [string stringByAppendingFormat:@"%@\n",[NSString stringAlixPaySourceApplication2]];
    string = [string stringByAppendingFormat:@"%@\n",[NSString stringAlixPayURLScheme]];
    string = [string stringByAppendingFormat:@"%@\n",[NSString stringWeiXinShareURLScheme]];
    string = [string stringByAppendingFormat:@"%@\n",[NSString stringSinaWeiBoShareURLScheme]];
    string = [string stringByAppendingFormat:@"%@\n",[NSString stringWanHuiURLScheme]];
    string = [string stringByAppendingFormat:@"%@\n",[NSString appID]];
    string = [string stringByAppendingFormat:@"%@\n",[NSString itunesDownloadAddress]];
    string = [string stringByAppendingFormat:@"%@\n",[NSString appID]];
    string = [string stringByAppendingFormat:@"%@\n",[NSString stringURLSchemeWithKeyword:@"tencentopenapi"]];
    
    string = [string stringByAppendingFormat:@"valatdd ===========\n"];
//    string = [string stringByAppendingFormat:@"%zd\n",[@"123er4" isNotEmpty]];
//    string = [string stringByAppendingFormat:@"%@\n",[@"  123  er4" trimWhiteCharacters]];
//    string = [string stringByAppendingFormat:@"%zd\n",[@"123er4" isWhitespaceAndNewlines]];
//    string = [string stringByAppendingFormat:@"%zd\n",[@"123er4" isEmptyOrWhitespace]];
//    string = [string stringByAppendingFormat:@"%zd\n",[@"123er4" containsString:@"3e"]];
//    string = [string stringByAppendingFormat:@"%zd\n",[@"123er4" isMobileNumber]];
//    string = [string stringByAppendingFormat:@"%zd\n",[@"123er4" isIDCardNumber]];
//    string = [string stringByAppendingFormat:@"%zd\n",[@"123er4" canTel]];
//    string = [string stringByAppendingFormat:@"%zd\n",[@"123er4" isNumber]];
//    string = [string stringByAppendingFormat:@"%zd\n",[@"123er4" hasPrefixWithWhiteSpaeOrPageHtml]];
//    string = [string stringByAppendingFormat:@"%zd\n",[@"123er4" containsString:@"123" options:NSCaseInsensitiveSearch]];
    
    NSString *sss = nil;
    string = [string stringByAppendingFormat:@"%zd\n",[sss isNotEmpty]];
    string = [string stringByAppendingFormat:@"%@\n",[sss trimWhiteCharacters]];
    string = [string stringByAppendingFormat:@"%zd\n",[sss isWhitespaceAndNewlines]];
    string = [string stringByAppendingFormat:@"%zd\n",[sss isEmptyOrWhitespace]];
    string = [string stringByAppendingFormat:@"%zd\n",[sss containsString:@"3e"]];
    string = [string stringByAppendingFormat:@"%zd\n",[sss isMobileNumber]];
    string = [string stringByAppendingFormat:@"%zd\n",[sss isIDCardNumber]];
    string = [string stringByAppendingFormat:@"%zd\n",[sss canTel]];
    string = [string stringByAppendingFormat:@"%zd\n",[sss isNumber]];
//    string = [string stringByAppendingFormat:@"%zd\n",[sss hasPrefixWithWhiteSpaeOrPageHtml]];
    string = [string stringByAppendingFormat:@"%zd\n",[sss containsString:@"123" options:NSCaseInsensitiveSearch]];
    
    /*
     
         
     - (BOOL)containsString:(NSString *)string options:(NSStringCompareOptions)options;
     
     typedef NS_OPTIONS(NSUInteger, NSStringCompareOptions) {
     NSCaseInsensitiveSearch = 1, 不区分大小写比较
     NSLiteralSearch = 2,		区分大小写比较
    NSBackwardsSearch = 4,		从字符串末尾开始搜索
    NSAnchoredSearch = 8,		搜索限制范围的字符串
    NSNumericSearch = 64,		按照字符串里的数字为依据，算出顺序。例如 Foo2.txt < Foo7.txt < Foo25.txt
     以下定义高于 mac os 10.5 或者高于 iphone 2.0 可用
    NSDiacriticInsensitiveSearch 忽略 "-" 符号的比较
    NSWidthInsensitiveSearch NS_ENUM_AVAILABLE(10_5, 2_0) = 256, 忽略字符串的长度，比较出结果
    NSForcedOrderingSearch NS_ENUM_AVAILABLE(10_5, 2_0) = 512, 忽略不区分大小写比较的选项，并强制返回 NSOrderedAscending 或者 NSOrderedDescending
    NSRegularExpressionSearch NS_ENUM_AVAILABLE(10_7, 3_2) = 1024   只能应用于 rangeOfString:..., stringByReplacingOccurrencesOfString:...和 replaceOccurrencesOfString:... 方法。使用通用兼容的比较方法，如果设置此项，可以去掉 NSCaseInsensitiveSearch 和 NSAnchoredSearch

     };



     
     */
    
    
    

    _tfView.text = string;
}

- (void)dateValidet {
    NSString *string = [NSString stringWithFormat:@"date validate\n\n%@\n",[NSDate dateTomorrow]];
    NSDate *date = [NSDate date];
    string = [string stringByAppendingFormat:@"date 方法=%@\n",[date relativedDateWithInterval:2]];
    string = [string stringByAppendingFormat:@"%@\n",[NSDate relativedDateWithInterval:2]];
    string = [string stringByAppendingFormat:@"%@\n",[NSDate dateWithString:@"2016/12/6 18:10:23" formate:@"YYYY-MM-dd HH:mm:ss"]];
    string = [string stringByAppendingFormat:@"%@\n",[date weekdayString]];
    string = [string stringByAppendingFormat:@"%@\n",[date dayTimeString]];
    string = [string stringByAppendingFormat:@"%@\n",[date stringWithSeperator:@":"]];
    string = [string stringByAppendingFormat:@"%@\n",[date stringWithFormat:@"YYYY-MM-dd"]];
    string = [string stringByAppendingFormat:@"%@\n",[date stringWithSeperator:nil includeYear:NO]];
    string = [string stringByAppendingFormat:@"%@\n",[NSDate timeStamp]];
    string = [string stringByAppendingFormat:@"%@\n",[NSDate stringTodayShow:[NSNumber numberWithInteger:1481019023]]];
    string = [string stringByAppendingFormat:@"%@\n",[NSDate hoursStringWithTime:[NSNumber numberWithInteger:1481019023]]];
    string = [string stringByAppendingFormat:@"%@\n",[NSDate timeStringWithInterval:1481107540562]];
    
    string = [string stringByAppendingFormat:@"%@\n",[NSDate stringWithDate:[NSDate dateWithString:@"2016/12/1 18:10:23" formate:@"YYYY-MM-dd HH:mm:ss"] format:@"YYYY-MM-dd HH:mm:ss Z"]];
    
    //////////////error test ////////////
    string = [string stringByAppendingFormat:@"======erro 测试======\n"];
    string = [string stringByAppendingFormat:@"date 方法=%@\n",[date relativedDateWithInterval:1]]; //>0之后多少天 <0之前多少天
    string = [string stringByAppendingFormat:@"%@\n",[NSDate relativedDateWithInterval:2]];
    string = [string stringByAppendingFormat:@"%@\n",[NSDate dateWithString:@"2016-12-06 18:10:23 +0800" formate:@"YYYY-MM-dd HH:mm:ss Z"]];
    string = [string stringByAppendingFormat:@"%@\n",[NSDate stringWithDate:[NSDate dateWithString:@"2016-12-06 18:10:23" formate:@"YYYY-MM-dd HH:mm:ss"] format:@"YYYY-MM-dd HH:mm:ss Z"]];
    string = [string stringByAppendingFormat:@"%@\n",[date stringWithSeperator:@"&&"]];//任意字符均可
    string = [string stringByAppendingFormat:@"%@\n",[date stringWithFormat:@"YYYY-MM-dd"]];
    
    string = [string stringByAppendingFormat:@"%@\n",[NSDate getDefaultTimeZone]];
    string = [string stringByAppendingFormat:@"%@\n",[date stringWithSeperator:nil includeYear:NO]];
    
    string = [string stringByAppendingFormat:@"\n\n%@\n",[date localeDate]];
    string = [string stringByAppendingFormat:@"%@\n",[date billMonthName]];
    string = [string stringByAppendingFormat:@"%@\n",[NSDate dateStringFromTimeStampString:@"1481019023000" withFormat:@"YYYY-MM-dd"]];
    //    + (NSString *)getStringFromStartTime:(NSNumber *)startTime
    //endTime:(NSNumber *)endTime
    //withSeparateString:(NSString *)middleString
    //withFormat:(NSString *)format
    
    /*    yyyy-MM-dd :yyyy是年份  MM是月份  dd是天
     
     2015年2月9号11点51分 应该这样表示：yyyy年MM月dd号HH点mm分
     
     特别注意 ：MM大写是月份 mm小写是分钟
     */
//    string = [string stringByAppendingFormat:@"%@\n",[FFDateTools getStringFromStartTime:[NSNumber numberWithInt:1481019023] endTime:[NSNumber numberWithInt:1481019098]]];
//    string = [string stringByAppendingFormat:@"%@\n",[FFDateTools getStringFromStartTime:[NSNumber numberWithInt:1481019023] endTime:[NSNumber numberWithInt:1481019098] withSeparateString:@" " withFormat:@"yyyy年MM月dd日"] ];
    
    NSDate *date2 = [NSDate date];
    NSLog(@"当前时间%@",date2);
    
    //2.打印出2011-11-12 23：10：34这种格式
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSString *dateStr = [dateFormatter stringFromDate:date2];
    NSLog(@"字符串表示1:%@",dateStr);
    
    //3.打印出2013年12月22日 12时34分56秒这个格式
    NSDateFormatter *dateFormaterA = [[NSDateFormatter alloc]init];
    [dateFormaterA setDateFormat:@"yyyy年MM年dd日 HH时mm分ss秒"];
    NSString *dateStrA = [dateFormaterA stringFromDate:date2];
    NSLog(@"%@",dateStrA);
    _tfView.text = string;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
